package mt.filter.messagewrapper;

import mt.Order;
import mt.comm.ServerSideMessage;

/**
 * ServerSideMessage decoration
 * Adds a time stamp property to the standard implementation
 * 
 */
public class TimeStampedServerSideMessage implements ServerSideMessage, Comparable<TimeStampedServerSideMessage>{
	private Order order;
	private Type type;
	private String senderNickname;
	private double timeStamp;
	
	
	public TimeStampedServerSideMessage(ServerSideMessage serverSideMessage, double timeStamp){
		this.order = serverSideMessage.getOrder();
		this.type = serverSideMessage.getType();
		this.senderNickname = serverSideMessage.getSenderNickname();
		this.timeStamp = timeStamp;
	}
	
	@Override
	public int compareTo(TimeStampedServerSideMessage timeStampedServerSideMessage) {
		return (int)(this.timeStamp - ((TimeStampedServerSideMessage)timeStampedServerSideMessage).timeStamp);
	}

	@Override
	public Type getType() {
		return type;
	}

	@Override
	public String getSenderNickname() {
		return senderNickname;
	}

	@Override
	public Order getOrder() {
		return order;
	}

	public double getTimeStamp() {
		return timeStamp;
	}

}
